@extends('wap.layout.base')
@section('scripts')
    <script src="{{ asset('js/moment.min.js') }}" type="text/javascript"></script>
    <script>
        $(function () {
            var app = new Vue({
                el: '#app',
                data: function() {
                    return {
                        title: '点赞记录',
                        listData: [],
                        pageData: {!! $lists !!},
                        finished: false,//是否已加载完成，加载完成后不再触发load事件
                        loading: false,//加载loading开关
                        params: {page : 2},
                    }
                },
                created(){
                    this.listData = this.pageData.data;
                },
                methods: {
                    list() {
                        let that = this;
                        this.finished = false;
                        this.loading = true;
                        setTimeout(()=>{
                            $.get("{{ route('wap.user.praise') }}",this.params,function(res){
                                that.pageData = res.data;
                                if(that.params.page == 1){
                                    that.listData = res.data.data;
                                }else{
                                    that.listData = that.listData.concat(res.data.data);
                                }
                                if((that.pageData.last_page == 1) || (that.params.page == that.pageData.last_page)){
                                    that.finished = true;
                                }
                                that.loading = false;
                                that.params.page ++;
                            })
                        },500);
                    },
                    info(id) {
                        window.open("{{ route('wap.new.info') }}"+'?id='+id, '_blank');
                    },
                    onClickLeft() {
                        window.location.href = "{{ route('wap.user.index') }}";
                    },
                }
            });
        })
    </script>
@endsection
@section('content')
    <div class="container main user-detail" id="app" v-cloak>
        <div class="row">
            <van-nav-bar
                    :title="title"
                    left-text=""
                    border
                    fixed="true"
                    left-arrow="false"
                    @click-left="onClickLeft">
                <van-icon name="arrow-left" slot="left"/>
            </van-nav-bar>
            <van-list
                    v-model="loading"
                    :finished="finished"
                    finished-text="没有更多了"
                    @load="list">
                <div class="col-xs-12" v-for="items in listData"  @click="info(items.article.id)">
                    <div class="main-item">
                        <div class="main-item-img">
                            <span class="tag-name" v-if="items.article.cate_child">@{{ items.article.cate_child.name }}</span>
                            <span class="tag-name none" v-else></span>
                            <img :src="items.article.thumb">
                        </div>
                        <div class="main-item-info">
                            <p class="info-title">@{{ items.article.title }}</p>
                            <p class="info-other">
                                <img :src="items.user.avatar">
                                <span class="info-other-name">
                                @{{ moment(items.article.created_at).format('YYYY-MM-DD') }}<i></i>
                            </span>
                                <span class="info-other-view"><i class="fa fa-thumbs-o-up"></i> @{{ items.article.praise }}</span>
                            </p>
                        </div>
                    </div>
                </div>
            </van-list>
        </div>
    </div>
@endsection

